package io.wins.vertx.entity;

import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.json.JsonObject;
import io.wins.vertx.utils.UUIDUtils;
import org.apache.commons.lang3.StringUtils;

@DataObject(generateConverter = true)
public class Goods {
    private final String id;
    private String title;
    private String poster;
    private String imageList;
    private String shortDesc;
    private String content;
    private float price;
    private int count;
    private String code;
    private boolean onSell;
    private boolean isDelete;
    private long createdOn;
    private long updatedOn;


    public Goods(final JsonObject json) {
        GoodsConverter.fromJson(json, this);
        this.id = StringUtils.isEmpty(json.getString("id")) ?
            UUIDUtils.genId() : json.getString("id");
    }

    public JsonObject toJson() {
        final JsonObject json = new JsonObject();
        GoodsConverter.toJson(this, json);
        return json;
    }

    public String getId() {
        return this.id;
    }

    public String getTitle() {
        return this.title;
    }

    public void setTitle(final String title) {
        this.title = title;
    }

    public String getPoster() {
        return this.poster;
    }

    public void setPoster(final String poster) {
        this.poster = poster;
    }

    public boolean isOnSell() {
        return this.onSell;
    }

    public void setOnSell(final boolean onSell) {
        this.onSell = onSell;
    }

    public String getImageList() {
        return this.imageList;
    }

    public void setImageList(final String imageList) {
        this.imageList = imageList;
    }

    public String getShortDesc() {
        return this.shortDesc;
    }

    public void setShortDesc(final String shortDesc) {
        this.shortDesc = shortDesc;
    }

    public String getContent() {
        return this.content;
    }

    public void setContent(final String content) {
        this.content = content;
    }

    public float getPrice() {
        return this.price;
    }

    public void setPrice(final float price) {
        this.price = price;
    }

    public int getCount() {
        return this.count;
    }

    public void setCount(final int count) {
        this.count = count;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(final String code) {
        this.code = code;
    }

    public boolean isDelete() {
        return this.isDelete;
    }

    public void setDelete(final boolean delete) {
        this.isDelete = delete;
    }

    public long getCreatedOn() {
        return this.createdOn;
    }

    public void setCreatedOn(final long createdOn) {
        this.createdOn = createdOn;
    }

    public long getUpdatedOn() {
        return this.updatedOn;
    }

    public void setUpdatedOn(final long updatedOn) {
        this.updatedOn = updatedOn;
    }
}
